<template>
	<view>
		<image src="/static/common/bg.png" class="pagebg" mode=""></image>
		<u-navbar :safeAreaInsetTop="true" title="我的收藏" :autoBack="true" :bgColor="'rgba(255,255,255,'+opc+')'"
			placeholder>

		</u-navbar>
		<view class="pagecon">
			<view class="pd30">
				<u-search placeholder="搜索商品关键词" bgColor="#f0f4f7" placeholderColor="#515151" v-model="keyword"
					:showAction='false' height="73rpx" @search="getList()"></u-search>
				<view class="title">
					我的收藏({{list.length}})
				</view>
			</view>
			<scroll-view scroll-y="true"
				:style="{height: 'calc(100vh - 44px - 80rpx - 10rpx - 100rpx - '+$u.addUnit($u.sys().statusBarHeight + $u.sys().safeAreaInsets.bottom,'px')+')'}">
				<view class="popbox__list">
					<view class="popbox__item" v-for="(item,index) in list" :key="index">
						<image :src="$getImg(item.image)" class="popbox__item__pic" mode="aspectFill"></image>
						<view class="" style="flex: 1;">
							<view class="u-flex u-flex-between" style="padding-top: 10rpx;">
								<view class="popbox__item__name">
									{{item.name}}
								</view>

							</view>
							<view class="u-flex u-flex-y-center" style="margin-top: 24rpx;">
								<view class="popbox__item__tag">
									库存{{item.num}}
								</view>
								<view class="popbox__item__tag tag1">
									销量{{item.salenum}}
								</view>
							</view>
							<view class="u-flex u-flex-between u-flex-items-end" style="margin-top: 52rpx;">
								<view class="popbox__item__price">
									{{item.price}}
								</view>
								<view class="popbox__item__btn">
									<view class="popbox__item__addcar">
										<image src="/static/post/car.png" class="popbox__icon" mode=""></image>
									</view>
									<view class="popbox__item__buy" @click="navto('/pages/goods/details?id='+item.id)">
										去购买
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {
		favoriteList
	} from "@/request/api/goods.js"
	export default {
		data() {
			return {
				opc: 0,
				keyword: '',
				list: []
			};
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				if(this.keyword){
					favoriteList({
						keyword:this.keyword
					}).then(res => {
						this.list = res.data.list;
					})
				}else{
					favoriteList().then(res => {
						this.list = res.data.list;
					})
				}
				
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}

	.pd30 {
		padding: 10rpx 30rpx 0;

	}

	.title {
		font-family: PingFang-SC, PingFang-SC;
		font-weight: 500;
		font-size: 24rpx;
		color: #545454;
		line-height: 100rpx;
	}

	.popbox {
		&__list {
			padding: 0 30rpx 2rpx;
		}

		&__icon {
			width: 34rpx;
			height: 31rpx;

		}

		&__item {
			display: flex;
			margin-bottom: 37rpx;

			&__pic {
				width: 207rpx;
				height: 210rpx;
				background: #896CAD;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin-right: 22rpx;
			}

			&__name {
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 30rpx;
				color: #1E1E1E;
				line-height: 30rpx;
			}

			&__tag {
				padding: 0 8rpx;
				height: 34rpx;
				background: rgba(69, 196, 123, .1);
				border-radius: 5rpx 5rpx 5rpx 5rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: 500;
				font-size: 20rpx;
				color: #45C47B;
				line-height: 34rpx;
			}

			.tag1 {
				color: #E3432D;
				background: rgba(227, 67, 45, .1);
				margin-left: 8rpx;
			}

			&__price {
				font-family: DINNextLTPro;
				font-weight: 500;
				font-size: 38rpx;
				color: #FD2A00;
				line-height: 38rpx;

				&::before {
					content: "￥";
					font-family: PingFang-SC, PingFang-SC;
					font-weight: 800;
					font-size: 25rpx;
					color: #FD2A00;
					line-height: 25rpx;
				}
			}

			&__btn {
				background: #FF4D30;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				overflow: hidden;
				display: flex;
				align-items: center;
			}

			&__addcar {
				width: 82rpx;
				height: 63rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background-color: #f0f4f7;
				-webkit-clip-path: polygon(0 0, 100% 0, 90% 100%, 0% 100%);
				clip-path: polygon(0 0, 100% 0, 90% 100%, 0% 100%);
			}

			&__buy {
				width: 150rpx;
				height: 63rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: 500;
				font-size: 27rpx;
				color: #FFFFFF;
				line-height: 40rpx;
			}
		}
	}
</style>